package m.html.util;

import m.common.action.Action;
import m.system.RuntimeData;

import java.util.HashMap;
import java.util.Map;

public class HtmlUtil {
    private final static Map<Class<? extends Action>,String> actionMap=new HashMap<>();

    /**
     * 根据类获取当前Action路径
     */
    public static String actionUrl(Class<? extends Action> clazz){
        String path=actionMap.get(clazz);
        if(null==path){
            Map<String, Class<? extends Action>> am=RuntimeData.getActionData();
            for(String key : am.keySet()){
                if(am.get(key).getName().equals(clazz.getName())){
                    path=key;
                    actionMap.put(clazz,path);
                }
            }
        }
        return "action/"+path;
    }
}
